import { getComplaintRiskInfo, getRegionalServiceInfo, getEfficiencyInfo, getFaultAreaInfo, getWorkNumberInfo } from '@/api/report'
const report = {
  state: {
    complainRiskData: [],
    regionalServiceData: [],
    efficiencyData: [],
    faultAreaData: [],
    workNumberData: []
  },
  mutations: {
    SET_COMPLAINRISKDATA: (state, complainRiskData) => {
      state.complainRiskData = complainRiskData
    },
    SET_REGIONALSERVICEDATA: (state, regionalServiceData) => {
      state.regionalServiceData = regionalServiceData
    },
    SET_EFFICIENCYDATA: (state, efficiencyData) => {
      state.efficiencyData = efficiencyData
    },
    SET_FAULTAREADATA: (state, faultAreaData) => {
      state.faultAreaData = faultAreaData
    },
    SET_WORKNUMBERADATA: (state, workNumberData) => {
      state.workNumberData = workNumberData
    }
  },
  actions: {

    // 获取投诉风险信息
    ComplainRiskGetInfo({ commit }) {
      return new Promise((resolve, reject) => {
        console.log('ComplainRiskGetInfo')
        getComplaintRiskInfo().then(response => {
          console.log('getInfo')
          const data = response.data
          commit('SET_COMPLAINRISKDATA', data)
          console.log(data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取全区域服务信息
    RegionalServiceGetInfo({ commit }) {
      return new Promise((resolve, reject) => {
        console.log('RegionalServiceGetInfo')
        getRegionalServiceInfo().then(response => {
          console.log('getInfo')
          const data = response.data
          commit('SET_REGIONALSERVICEDATA', data)
          console.log(data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取服务效能信息
    EfficiencyGetInfo({ commit }) {
      return new Promise((resolve, reject) => {
        console.log('EfficiencyGetInfo')
        getEfficiencyInfo().then(response => {
          console.log('getInfo')
          const data = response.data
          commit('SET_EFFICIENCYDATA', data)
          console.log(data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取故障区域信息
    FaultAreaGetInfo({ commit }) {
      return new Promise((resolve, reject) => {
        console.log('FaultAreaGetInfo')
        getFaultAreaInfo().then(response => {
          console.log('getInfo')
          const data = response.data
          commit('SET_FAULTAREADATA', data)
          console.log(data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取工单数量信息
    WorkNumberGetInfo({ commit }) {
      return new Promise((resolve, reject) => {
        console.log('WorkNumberGetInfo')
        getWorkNumberInfo().then(response => {
          console.log('getInfo')
          const data = response.data
          commit('SET_WORKNUMBERADATA', data)
          console.log(data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default report
